//
//  SY_FunctionView.m
//  ChatDemo-UI2.0
//
//  Created by Sylar on 16/10/9.
//  Copyright © 2016年 Sylar. All rights reserved.
//

#import "SY_FunctionView.h"

@implementation SY_FunctionView

-(instancetype)initWithFrame:(CGRect)frame{
    
    if (self = [super initWithFrame:frame]) {
        
        _bgImageView = [[UIImageView alloc] init];
        _bgImageView.contentMode = UIViewContentModeScaleAspectFill;
        [self addSubview:_bgImageView];
        
        _unreadImg = [[UIImageView alloc] init];
        [_unreadImg setImage:[UIImage imageNamed:@"content_remind_"]];
        [self addSubview:_unreadImg];
        
        
        _label = [[UILabel alloc] init];
        _label.font = [UIFont systemFontOfSize:14];
        _label.textColor = [UIColor colorWithHexString:@"#979797"];
        _label.textAlignment = NSTextAlignmentCenter;
        [self addSubview:_label];
       
       _unreadView = [[UIView alloc] initWithFrame:CGRectMake(_bgImageView.right - 2, _bgImageView.top, 18, 18)];
       _unreadView.layer.cornerRadius = 7;
       [_unreadView setBackgroundColor:colorFromHex(@"#fed516")];
       _unreadView.hidden = YES;
       [self addSubview:_unreadView];
       
       _unreadLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 18, 18)];
       _unreadLabel.font = [UIFont systemFontOfSize:11];
       _unreadLabel.textColor = [UIColor whiteColor];
       _unreadLabel.textAlignment = NSTextAlignmentCenter;
       [_unreadView addSubview:_unreadLabel];
        
        [_bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            
            make.centerX.equalTo(self.mas_centerX).offset(0);
            make.top.equalTo(self.mas_top).offset(34);
            make.width.equalTo(@45);
            make.height.equalTo(@45);
        }];
        
        [_label mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self.mas_centerX).offset(0);
            make.width.equalTo(self.mas_width);
            make.height.equalTo(@(14));
            make.top.equalTo(self.mas_bottom).offset(-16);
        }];
        
        [_unreadImg mas_makeConstraints:^(MASConstraintMaker *make) {
            
            make.width.equalTo(@9);
            make.height.equalTo(@9);
            make.centerX.equalTo(self.bgImageView.mas_right).offset(2);
            make.centerY.equalTo(self.bgImageView.mas_top).offset(0);
        }];
       
       [_unreadView mas_makeConstraints:^(MASConstraintMaker *make) {
          
          make.width.equalTo(@18);
          make.height.equalTo(@18);
          make.centerX.equalTo(self.bgImageView.mas_right).offset(0);
          make.centerY.equalTo(self.bgImageView.mas_top).offset(0);
       }];
       
       [_unreadLabel mas_makeConstraints:^(MASConstraintMaker *make) {
          
          make.width.equalTo(@18);
          make.height.equalTo(@18);
          make.centerX.equalTo(self.bgImageView.mas_right).offset(0);
          make.centerY.equalTo(self.bgImageView.mas_top).offset(0);
       }];
       
      
       
    }
    
    return self;
}

@end
